package com.adinnet.api.common.service.async;

import com.adinnet.common.jpush.PushBean;
import com.adinnet.common.jpush.PushService;
import com.adinnet.core.redis.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import lombok.extern.slf4j.Slf4j;

/**
 * 异步处理的任务
 */
@Slf4j
@Component
public class AsyncHandlerTask {

	@Autowired
	@Lazy
	private RedisService redisService;

	@Autowired
	@Lazy
	private PushService pushService;

	/**
	 * 发送系统消息
	 */
	@Async("taskExecutor")
	public void sendSystemInform(PushBean pushBean, String jpushId){
		try {
			log.info("系统消息极光推送开始");
			pushService.pushAndroid(false,pushBean,jpushId);
			pushService.pushIos(true,pushBean,jpushId);
		}catch (Exception e){
			log.error("系统消息极光推送失败处理异常：{}",e);
			e.printStackTrace();
		}
	}

}
